<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

class Question extends Model
{
    protected $table='questions';
    protected $guarded = [];
    public $timestamps = false;


    public function questionnaire()
    {
        return $this->belongsTo('App\Models\Questionnaire');
    }

    public function getOptionAttribute($val){
        $value = collect(explode(',',$val))->map(function ($v,$k){
            return array('q'=>$v);
        });
        return $value;
    }

    public function getAnswerAttribute($val){

        return explode(',',$val);
    }

}
